安装Apache

1
yum install httpd

启动Apache

1
systemctl start httpd

设置自启动

1
systemctl enable httpd

防火墙永久打开80端口

1
2
firewall-cmd --add-service=http --permanent
#返回 success

重启防火墙

1
systemctl restart firewalld

这时我们访问ip地址可以看见Apache的默认主页

安装php及基础支持

1
yum install php php-mysql php-pdo php-gd php-mbstring

新建vhost.conf于/etc/httpd/conf.d

1
2
3
4
5
6
7
8
9
10
# 虚拟主机
<VirtualHost *:80>
ServerName blog.kozzzx.com
DocumentRoot "/var/www/blog"
</VirtualHost>
# 虚拟主机2
<VirtualHost *:80>
ServerName blog2.kozzzx.com
DocumentRoot "/var/www/blog2"
</VirtualHost>

重启Apache

1
systemctl restart httpd